<template>
	<view class="content">
		<view class="user-info">
			<view class="topView">
				<image class="setIcon" src="../../static/universal_back_trans.png" mode="widthFix" @click="toSetting"></image>
			</view>
		</view>
		<view class="view1">
			<image src="../../static/enter_type_scan.png" mode="widthFix" @click="gotoScan"></image>
			<view class="Name">{{msgDict.scanQRcode}}</view>
		</view>
		<view class="view1">
			<image src="../../static/enter_type_input.png" mode="widthFix" @click="gotoInput"></image>
			<view class="Name">{{msgDict.inputCode}}</view>
		</view>
	</view>
</template>

<script>
	import {schoolInfo} from '../../api/index.js'
	export default {
		data() {
			return {
				msgDict:{}
			}
		},
		onLoad() {
			this.msgDict = getApp().globalData.$t('infoCenter');
		},
		methods: {
			//校验学校吗
			async NewsendSms(schoolCode){
				// console.log('手机号码',schoolCode)
			  	try{
					
					let {result} = await schoolInfo({schoolCode:schoolCode});
					uni.showToast({
						icon:'none',
						title:this.msgDict.scanSuccess
						
					},400)
					setTimeout(()=>{
						uni.navigateTo({
							url:'../loginTwoInfutDetail/loginTwoInfutDetail?item=' + encodeURIComponent(JSON.stringify(result))
						})
					},500)
					
					
					
				} catch(err) {
					console.log('我请求啦',err);
					uni.showToast({
						title:err.message,
						icon:'none'
					})
				}
			},
			gotoScan(){
				// console.log('电话号码');
				uni.scanCode({
					scanType:['qrCode'],
					success:(info)=> {
						// console.log('电话号码',info);
						if (info.errMsg == "scanCode:ok") {
							let school = info.result;
							
							if (school.length== 4) {
								
								this.NewsendSms(school);

							} else{
								uni.showToast({
									icon:'none',
									title:this.msgDict.scanSchool
									
								})
							}
							
						} else{
							uni.showToast({
								icon:'none',
								title:this.msgDict.scanError
								
							})
						}
						
					},
					fail(errInfo) {
						console.log('电话号码errInfo',errInfo);
					}
				})
			},
			gotoInput(){
				uni.navigateTo({
					url:'../loginTwoInPut/loginTwoInPut'
				})
				
			},
			toSetting(){
				uni.navigateBack({
					delta:1
				})
			}
			
			
		}
	}
</script>

<style>
	.user-info {
			// width: 100%;
			height: 150rpx;
			background-color: #fff;
			padding: 20rpx;

		}
		.topView{
			
			/* #ifdef APP-PLUS */
		    padding-top: calc(22upx + var(--status-bar-height));
			/* #endif */
			/*#ifdef MP-WEIXIN */
			padding-top: calc(22upx + var(--status-bar-height));
			/* #endif */
			/*#ifdef H5 */
			padding-top: calc(48upx + var(--status-bar-height));
			/* #endif */
			display: flex;
			justify-content: space-between;
			
			
			
			
		}
		.setIcon{
			
			width: 60rpx;
			height: 60rpx;
		}
		.lab2{
			display: flex;
			
			align-items: center;
			font-size: 28upx;
			color: #888;
			
		}
    .view1{
		margin: 100rpx auto 0;
		width: 300rpx;
		height: 350rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		
	}
	.view1 image{
		width: 250rpx;
		height: 250rpx;
		
	}
	.Name{
		color: #000;
		font-size: 32rpx;
		margin-top: 30rpx;
		font-weight: 400;
	}
</style>
